package com.managerstudy.managerback.controller;


import com.fasterxml.jackson.databind.ser.Serializers;
import com.github.pagehelper.PageInfo;
import com.managerstudy.managerback.entity.Employee;
import com.managerstudy.managerback.service.EmployeeService;
import com.managerstudy.managerback.utils.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import static com.managerstudy.managerback.utils.BaseResult.success;

@RestController
public class hello {



    @Autowired
    private EmployeeService employeeService;

    @GetMapping("/hello")
    public BaseResult Hello() {
       return success("hello");
    }

    @GetMapping("/p")
    public int error() {
        int sum =11/0;
        return sum;

    }

    @GetMapping("/get")
    public BaseResult get(@RequestParam Integer pageNum,@RequestParam Integer pageSize) {
        PageInfo<Employee> pageInfo = employeeService.getAll(pageNum,pageSize);
        return BaseResult.success(pageInfo);
    }

    @GetMapping("/{id}")
    public BaseResult selectById(@PathVariable int id) {
        return BaseResult.success(employeeService.selectById(id));
    }
}
